{% extends "base.html" %}

{% load crispy_forms_tags emojificate i18n package_tags page_metadata_tags profile_tags %}

{% block metadata %}
    {% translate "Profile for " as trans_title %}
    {% page_metadata page_title=trans_title|add:user.username %}
{% endblock metadata %}

{% block body %}
    <div class="row">
        <div class="col-xs-2">
            <h2>{% blocktranslate %}<span class="fn nickname">{{ user }}</span>{% endblocktranslate %}</h2>

            {% if request.user == user %}
                <p><a href="{% url 'profile_edit' %}">{% translate "Edit my profile" %}</a></p>
            {% endif %}

            {% if local_profile.github_account %}
                <p><b>{% translate "GitHub account" %}</b>:
                    <span class="fn"><a href="https://github.com/{{ local_profile.github_account }}" target="_blank">{{ local_profile.github_account }}</a></span>
                </p>
            {% endif %}

            {% if local_profile.bitbucket_url %}
                <p><b>{% translate "Bitbucket account" %}</b>:
                    <span class="fn"><a href="https://bitbucket.org/{{ local_profile.bitbucket_url }}" target="_blank">{{ local_profile.bitbucket_url }}</a></span>
                </p>
            {% endif %}

            {% if local_profile.gitlab_url %}
                <p><b>{% translate "GitLab account" %}</b>:
                    <span class="fn"><a href="https://gitlab.com/{{ local_profile.gitlab_url }}" target="_blank">{{ local_profile.gitlab_url }}</a></span>
                </p>
            {% endif %}

            {% if extra_fields %}
                {% for field in extra_fields %}
                    <p><b>{{ field.label }}:</b> {{ field.url|urlize }}</p>
                {% endfor %}
            {% endif %}
        </div>

        <div class="col-xs-10">


            {% if local_profile.my_packages %}
                <div class="col-xs-6">

                    <h3>{% translate "Packages Contributed To" %}</h3>
                    <table class="table">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>{% translate "Package" %}</th>
                                <th>{% translate "Repo" %}</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for package in local_profile.my_packages %}
                                <tr>
                                    <td>{{ forloop.counter }}</td>
                                    <td><a href="{{ package.get_absolute_url }}">{{ package.title|emojify|emojificate }}</a></td>
                                    <td><a href="{{ package.repo_url }}">{{ package.repo.title }}</a></td>
                                </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>

            {% endif %}



            {% if favorite_packages %}
                <div class="col-xs-6">

                    <h3>{% translate "Favorite packages" %}</h3>
                    <table class="table">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>{% translate "Package" %}</th>
                                <th>{% translate "Repo" %}</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for package in favorite_packages %}
                                <tr>
                                    <td>{{ forloop.counter }}</td>
                                    <td><a href="{{ package.get_absolute_url }}">{{ package.title|emojify|emojificate }}</a></td>
                                    <td><a href="{{ package.repo_url }}">{{ package.repo.title }}</a></td>
                                </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>

            {% endif %}
        </div>
    </div>
{% endblock body %}
